package com.yq.homework.day22;

import java.time.chrono.IsoChronology;
import java.util.Arrays;
import java.util.Random;
import java.util.zip.CheckedOutputStream;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/22 19:37
 * (选做)创建一个长度是100的字符串数组 使用长度是2的随机字符填充该字符串数组
 * 统计这个字符串数组里重复的字符串有多少种(忽略大小写)
 * 例如 输出: 20个字符串一行
 * 共5行 01 0S 1M 1q 20 2R 2S 3d 3k 3x 43 4A 4R 5T 7C 7U 7e
 * 7k 80 88 8p AD AG AY BF BO Db E2 Eg El GF Gm HC HO IB If
 * J0 JY Jv KW L0 LT MA NL NL NU PY Qx Rr Ry SB So TH Tu UR
 * VD WR Xe Xw Xx Y3 YL Yd Yk a3 aL bW bq cI cv cv dg eL fL
 * gA gL gh h4 hm j7 jp kN m1 mS o6 pQ qV rP rf s7 sA um vE
 * vP vb w6 wB xP yK yQ
 * El发生了重复 重复了2次
 * NL发生了重复 重复了2次
 * Yk发生了重复 重复了2次
 * cv发生了重复 重复了2次
 */
public class Demo05 {
    public static void main(String[] args) {
        //随机生成字符串
        String[] s1 = new String[100];
        for (int i = 0; i < 100; i++) {
            String s2 = get(2);
            s1[i] = s2;

        }
        for (int i = 0; i < s1.length; i++) {
            if (i%20==0){
                System.out.println();
            }
            System.out.print(s1[i]+" ");
        }
        int count= 0;

        for (int i = 0; i <100 ; i++) {
            for (int j = i+1; j <100 ; j++) {
                if (s1[i].equals(s1[j])){
                    count++;
                    System.out.println();
                    System.out.print(s1[i]+"");
                }
            }
        }
        System.out.println(count);


    }

    public static String get(int a) {
        Random random = new Random();
        String s = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < a; i++) {
            int r1 = random.nextInt(62);
            stringBuffer.append(s.charAt(r1));
        }

        return stringBuffer.toString();
    }


}
